<?php
/**
 * 对php系统函数的扩展的函数类
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/20/020
 * Time: 13:45
 */

namespace Common\helper;


class SysHelper
{
    /**
     * 计算一个月中有几天，兼容 扩展丢失的情况
     *   demo: $daysInOneMonth= self::daysInAMonth('CAL_GREGORIAN',$vMonth,$year[$key]);
     * //cal_days_in_month(CAL_GREGORIAN,$vMonth,$year[$key]);//一个月有几天
     * @param $calendar
     * @param $month
     * @param $year
     * @return false|int|string
     */
    public static function daysInAMonth($calendar, $month, $year){
        if (!function_exists('cal_days_in_month')){
            return date('t', mktime(0, 0, 0, $month, 1, $year));
        } else{
            return cal_days_in_month(CAL_GREGORIAN,$month,$year);//一个月有几天
        }
    }

}